package com.wz.dao;

import com.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserDao {

    //在dao层 写增删改查开头的方法 ,这个save是保存方法,实际上用来注册注册用户
    @Insert("insert into user(uuid,userName,password,realName,gender,birthday) values(#{uuid},#{userName},#{password},#{realName},#{gender},#{birthday})")
    int save(User user);

    //此方法是查询所有用户,但是在userservice层的逻辑是:分页查询用户
    @Select("select * from user")
    List<User> findAll();

    //此方法是修改用户信息
    @Update(" update user set userName=#{userName},password=#{password},realName=#{realName},gender=#{gender},birthday=#{birthday} where uuid=#{uuid}")
    int update(User user);
    
    //查询单个用户信息
    @Select("select * from user where uuid = #{uuid}")
    User get(Integer uuid);
    
    //删除用户
    @Delete("delete from  user where uuid = #{uuid}")
    int delete(Integer uuid);


}
